package com.ycrlkj.android.modulescore.main.viewmodel;

import android.annotation.SuppressLint;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
import com.ycrlkj.android.modulescore.main.entity.XxStation;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class XxStationViewModel extends ViewModel {

    public MutableLiveData<XxStation> xxStation;
    public MutableLiveData<String []> dates;

    public MutableLiveData<XxStation> getXxStation(){
        if(xxStation == null){
            xxStation = new MutableLiveData<>();
            xxStation.setValue(new XxStation());
        }
        return xxStation;
    }

    public MutableLiveData<String []> getDates(){

        if(dates == null){
            dates = new MutableLiveData<>();

            @SuppressLint("SimpleDateFormat")
            SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");

            Date todayDate = new Date();
            String today = sd.format(todayDate);

            Calendar calendar = new GregorianCalendar();
            calendar.setTime(todayDate);

            calendar.add(Calendar.DATE, 1);
            String tomorrow = sd.format(calendar.getTime());

            calendar.add(Calendar.DATE, 1);
            String thirdDay = sd.format(calendar.getTime());

            String[] arr = {"请选择", today, tomorrow, thirdDay};

            dates.setValue(arr);
        }

        return dates;
    }
}
